<template>
	<view class="page">
	    <web-view v-if="url" :src="url" @message="get_msg"></web-view>
		<view class="box" v-else>
			<rich-text :nodes="html"></rich-text>
			<view class="safearea-bottom"></view>
		</view>
	</view>
</template>

<script>
	const app = getApp();
	let that;
	export default {
		data() {
			return {
				title: '用户协议',
				type: 'agreement',
				url: '',
				html: ''
			}
		},
		onLoad(e) {
		    that = this;
			let title_arr = {
				agreement: '用户协议',
				privacy: '隐私政策'
			};
		    if(e.url) that.url = decodeURIComponent(e.url);
		    if(e.type){
				that.type = e.type;
				if(title_arr[that.type] != undefined) that.title = title_arr[that.type];
				if(e.title != undefined) that.title = e.title;
				uni.setNavigationBarTitle({title: that.title});
				that.get_data();
			}
		},
		methods: {
			get_data(){
				that.http.get_curl('init/help',{type:that.type},function(res){
					if(res.code == 1){
						that.html = res.data.html;
					}
				});
			},
			get_link(url){
				uni.navigateTo({
					url: '../'+url
				});
			},
			//消息通信
			get_msg(e){
			    let msg = e.detail.data[0];
			}
		},
	}
</script>

<style>
	page{width: 100%;height: 100%;}
	.page{padding: 20rpx 32rpx;color:#666;}
	h3{color:#333;}
</style>